<template>
  <div>
    <div class="exam-id-type-radio">
      <el-radio v-model="type" label="0">条形码</el-radio>
      <el-radio v-model="type" label="1">准考证号</el-radio>
    </div>
    <el-input-number
      v-if="type === '1'"
      size="mini"
      :min="6"
      :max="13"
      v-model="count"
    ></el-input-number>
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex';

export default {
  data() {
    return {
      type: '1',
      count: 8,
    };
  },
  computed: {
    ...mapState([
      'examIdType',
      'examIdCount',
    ]),
  },
  watch: {
    examIdType(val) {
      this.type = val;
    },
    type(val) {
      this.updateExamIdType(val);
    },
    count(val) {
      this.updateExamIdCount(val);
    },
  },
  created() {
    this.type = this.examIdType;
    this.count = this.examIdCount;
  },
  methods: {
    ...mapMutations([
      'updateExamIdType',
      'updateExamIdCount',
    ]),
  },
};
</script>

<style lang="less" scoped>
.exam-id-type-radio {
  margin-bottom: 10px;
}
</style>
